<?php 
define('ZHMVC_VERSION', '2.0.0 Alpha');
define('ZH', '.php');
define('LOG', '.log');
define('DS', DIRECTORY_SEPARATOR);
define('ZH_PATH',dirname(dirname(__FILE__)));//定义系统目录
define('ISZHMVCBUG',true);//定义是否调试
define('SIGNATURENEW','hbcheng');
header('Access-Control-Allow-Origin:*');

if(ISZHMVCBUG==true)
{
    error_reporting(E_ALL);
    ini_set('display_errors', '1');
}
else
{
    error_reporting(0);//E_ALL 0
    ini_set('display_errors', '0');//1 0
}
include_once(ZH_PATH.DS."common".DS."tool".DS."Fun".ZH);
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>安装程序</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="js/jquery.js"></script>
</head>
<body>
<div class="top">
	<div class="top-logo">
	</div>
	<div class="top-link">
		<ul>
			<li><a href="#" target="_blank">官方网站</a></li>
			<li><a href="#" target="_blank">技术论坛</a></li>
			<li><a href="#" target="_blank">帮助</a></li>
		</ul>
	</div>
	<div class="top-version">
		<!-- 版本信息 -->
		<h2>YIGECMS安装</h2>
	</div>
</div>
<div class="main">
	<div class="pleft">
		<dl class="setpbox t1">
			<dt>安装步骤</dt>
			<dd>
				<ul>
					<li class="succeed">许可协议</li>
					<li class="succeed">环境检测</li>
					<li class="succeed">参数配置</li>
					<li class="now">正在安装</li>
					<li>安装完成</li>
				</ul>
			</dd>
		</dl>
	</div>
    <div class="pright">
  <!--右边-->
  <form action="" method="get">
  <div class="index_mian_right_one_ly">
  <div class="index_mian_right_one_one_ly"><span>正在配置数据库链接</span></div>
  <?php 
  $host=SafeRequest(getPGC("host"),0);
  $user=SafeRequest(getPGC("user"),0);
  $pass=SafeRequest(getPGC("pass"),0);
  $dbname=SafeRequest(getPGC("dbname"),0);
  $adminuser=SafeRequest(getPGC("adminuser"),0);
  $adminpass=SafeRequest(getPGC("adminpass"),0);
  $yuming=SafeRequest(getPGC("yuming"),0);
  $webname=SafeRequest(getPGC("webname"),0);
  $managerpath=SafeRequest(getPGC("managerpath"),0);
  
  
  $config_template='<?php
define("ZH", ".php");
define("LOG", ".log");
define("DS", DIRECTORY_SEPARATOR);
define("ZH_PATH",dirname(dirname(__FILE__)));
define("ISZHMVCBUG",false);//定义是否调试
define("SIGNATURENEW","lzbanzhu202301");
define("MANAGERFPATH","'.$managerpath.'");
define("XCXAPPID","wxb9c0587c5a3a9d28");
define("XCXAPPSECRET","2ed68457413b162793b06c67efb99609");
header("Access-Control-Allow-Origin:*"); 

// 启动程序时间
define("START_TIME", microtime(true));

// 设置字符集编码、IE文档模式
header("Content-Type:text/html; charset=utf-8");
header("X-UA-Compatible:IE=edge,chrome=1");
header("X-Powered-By:ZHMVC");
// PHP版本检测
if (PHP_VERSION < "5.4") {
    header("Content-Type:text/html; charset=utf-8");
    exit("您服务器PHP的版本太低，程序要求PHP版本不小于5.4");
}

if(ISZHMVCBUG==true)
{
    error_reporting(E_ALL);
    ini_set("display_errors", "1");
}
else
{
    error_reporting(0);//E_ALL 0
    ini_set("display_errors", "0");//1 0
}
if (! isset($_SESSION)) {
    session_start();
}

include_once(ZH_PATH.DS."common".DS."tool".DS."Fun".ZH);
include_once(ZH_PATH.DS."common".DS."ZhLoader".ZH);
include_once(ZH_PATH.DS."vendor".DS."autoload".ZH);
include_once(ZH_PATH.DS."zhconfig".DS."version".ZH);

$path=ZH_PATH."/s/t/default/";
$path1="/s/t/default/";
$sysconn = new \ZHMVC\D\SystemConfig();
$srs1 = $sysconn->getOne1("`name`=\'cfg_tpl_dir\'");
$srsnum1 = $sysconn->getRows();
if($srsnum1>0)
{
    $path=ZH_PATH.$srs1["value"].DS;
    $path1=$srs1["value"].DS;
}
$banzhudomain="http://'.$yuming.'";
$srs1 = $sysconn->getOne1("`name`=\'SiteUrl\'");
$srsnum1 = $sysconn->getRows();
if($srsnum1>0)
{
    $banzhudomain=$srs1["value"];
}
define("BANZHUDOMAIN",$banzhudomain);
$smarty = new \Smarty();
$smarty->setTemplateDir($path);
$smarty->setCompileDir(ZH_PATH.DS."data".DS."smartycompile".DS);
$smarty->setCacheDir(ZH_PATH.DS."data".DS."cache".DS);
$smarty->caching = true;
$smarty->debugging = FALSE;
$smarty->debug_tpl = ZH_PATH.DS."/mod/smarty/debug.tpl";
$smarty->debugging_ctrl = "URL";
$smarty->cache_lifetime = 300;
$smarty->left_delimiter  = "{@#";
$smarty->right_delimiter = "#@}";

$CssRand=getRandChar(6);
$smarty->assign("CssRand", $CssRand);
$smarty->registerPlugin("function", "RepModule", "RepModule");
$smarty->registerPlugin("function", "RepPlus", "RepPlus");
$smarty->assign(\'PageCss\',\'<LINK href="/common/css/pagecss.css" type="text/css" rel="stylesheet">\');
$smarty->assign("cfg_tpl_dir", $path1);

//getTemplateCommon($smarty);';
  
  
  $filepath1=ZH_PATH.DS.'zhconfig'.DS.'Config'. ZH;
  $fp = fopen($filepath1,'w');
  fwrite($fp,$config_template);
  fclose($fp);
  
  $ZhConfig_template='<?php
namespace ZHCONFIG;
class ZhConfig{
	private $db_host="";//MYSQL数据库服务器IP
	private $db_user="";//用户名
	private $db_pass="";//密码
	private $db_database="";//使用库
	private $db_charset="";//mysql数据采集模式,在建立表的时候可定义模式
	private $db_pre="";//mysql数据采集模式,在建立表的时候可定义模式
    
	public function __construct(){
	    $this->db_host="'.$host.'";//MYSQL数据库服务器IP
	    $this->db_user="'.$user.'";//用户名
	    $this->db_pass="'.$pass.'";//密码
	    $this->db_database="'.$dbname.'";//使用库
	    $this->db_charset="utf8";//mysql数据采集模式,在建立表的时候可定义模式
	    $this->db_pre="zhmvc_";//mysql数据采集模式,在建立表的时候可定义模式
	}
	public function getDbPre(){
	    return $this->db_pre;
	}
    
	public function getHost(){
		return $this->db_host;
	}
    
	public function getUser(){
		return $this->db_user;
	}
    
	public function getPassWord(){
		return $this->db_pass;
	}
    
	public function getDatabase(){
		return $this->db_database;
	}
    
	public function getCharset(){
		return $this->db_charset;
	}
}
';
  
  $filepath1=ZH_PATH.DS.'zhconfig'.DS.'ZhConfig'. ZH;
  $fp = fopen($filepath1,'w');
  fwrite($fp,$ZhConfig_template);
  fclose($fp);
  
  //修改管理文件夹名
  $oldname=ZH_PATH."/manager";
  $newname=ZH_PATH."/".$managerpath;
  rename($oldname, $newname);
  ?>
   <div class="font">配置成功！3秒后安装数据库</div>
   <div class="btn">
   	<script>
    window.location.href='instal__az1.php?adminuser=<?php echo $adminuser;?>&adminpass=<?php echo $adminpass;?>&yuming=<?php echo $yuming;?>&webname=<?php echo $webname;?>&managerpath=<?php echo $managerpath;?>';
    </script>
   </div>
  </div>
  <!--进入系统-->
  <div class="btnn-box"></div>
  </form>
</div>
</body>
</html>
